﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Transactions;

namespace DAL._4_RepositoryImplement
{
    public class OrderRepository : TestBase<Order_Info>
    {
        public OrderRepository()
        {

        }

        public OrderRepository(IUnitOfWork db)
            : base(db)
        {

        }
        /// <summary>
        /// 对于插入多表时，需要使用带参数的构造方法
        /// </summary>
        /// <param name="entity"></param>
        public override void Insert(Order_Info entity)
        {
            using (TransactionScope trans = new TransactionScope())
            {
                try
                {
                    base.Insert(entity);
                    new TestBase<Order_Detail>(IUnitOfWork).Insert(entity.Order_Detail);
                    trans.Complete();
                }
                catch (Exception)
                {

                    throw;
                }
            }

        }
    }
}